/*
** 2371.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Mon Sep 22 14:35:24 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/*
 * STRING.H: use some powerful mem* functions, high efficiency
 */

/* #include "2371.h" */
#include <stdio.h>
#include <string.h>

int main()
{
     int nat_num[5001];
     int database[100000];
     int i;
     int *index;
     int N, K;

     memset(nat_num, 0, 20004);	/* memset is char wide */

     scanf("%d", &N);
     while(N){
	  scanf("%d", nat_num);
	  nat_num[nat_num[0]]++;
	  N--;
     }

     for(i = 1, index = database; i < 5001; i++)
	  if (nat_num[i])	/* the number presented during input */
	       while(nat_num[i]){
		    *index = i;
		    nat_num[i]--;
		    index++;
	       }
     scanf("%s");
     scanf("%d", &K);
     while(K){
	  scanf("%d", nat_num);
	  printf("%d\n", database[nat_num[0] - 1]);
	  K--;
     }
     
     return 0;
}
